let vm = new Vue({
    el:'.main-container',  //选中整个main
    data(){
        return{
            role:{},
            yxUsers:{},
            resources:{}
        }
       //初始化对象     vue建议声明对象同时进行初始化，避免undefinded
    },
    methods:{
        //对已选的用户的处理
        //读取已选的用户
        selectRole:function(rid){
            axios({
                url: `/guguanjia/manager/user/selectUserById/${rid}` //相对路径同样受到base标签影响
            }).then(
                response => {  //省略function关键字  自动传递上下文中的this
                    this.yxUsers=response.data.obj;
                }
            ).catch(error => {
                console.log(error.message);
            })
        },
        todetil:function (id,companyName,roleName) {
            // this.selectOne(id);
            // debugger;
            axios({
                url: `/guguanjia/manager/user/selectOne/${id}` //相对路径同样受到base标签影响
            }).then(
                response => {  //省略function关键字  自动传递上下文中的this
                    let user=response.data.obj;
                    user.companyName = companyName;
                    user.roleName = roleName;
                    layer.obj = user;
                    layer.open({
                        type: 2,
                        title: '分配用户详情',
                        maxmin: true,
                        shadeClose: true, //点击遮罩关闭层
                        area : ['60%' , '60%'],
                        content: 'user/user-detail.html',
                    });
                }
            ).catch(error => {
                console.log(error.message);
            });
        },
        getResourceByRid:function (rid) {
            axios({
                url: `/guguanjia/manager/menu/getResourceByRid/${rid}` //相对路径同样受到base标签影响
            }).then(
                response => {  //省略function关键字  自动传递上下文中的this
                    this.resources=response.data.obj;
                }
            ).catch(error => {
                console.log(error.message);
            })
        }
    },
    created:function () {
        this.role = parent.layer.obj;
        this.selectRole(this.role.id);
        this.getResourceByRid(this.role.id);
    }
});